package foo;

import java.io.IOException;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(value = "/VulnerableServlet")
public class Servlet extends HttpServlet {
  private static final long serialVersionUID = 1L;

  private static final String FIELD_NAME = "FIELD_KEY";

  @Override
  public void doPost(HttpServletRequest taintedRequest, HttpServletResponse response) throws ServletException, IOException {
    response.setHeader("Content-Type", "text/html; charset=UTF-8");

    String taintedString = taintedRequest.getParameter(FIELD_NAME);
    try {
      new FileWithSink().sinkMethod(taintedString);
    } catch (SQLException e) {
    }
  }

}
